import React from 'react';
// 高阶组件 formProvider表单验证
import formProvider from '../hoc/formProvider';

// 添加用户组件
class High extends React.Component{
    constructor(props){
        super(props)
        this.handleSubmit=this.handleSubmit.bind(this)
    }
    handleSubmit(){
        console.log(this.props.form)
    }
    render() {
        let {form:{password,userName},onChange}=this.props;
        return(
            <div>
                <div>
                    <input type="text" onChange={(e)=>onChange('userName',e.target.value)} placeholder={'请输入用户名'}/>
                    <div>{userName.msg}</div>
                </div>
                <div>
                    <input type="text" onChange={(e)=>onChange('password',e.target.value)} placeholder={'请输入手机号'}/>
                    <div>{password.msg}</div>
                </div>

                <div onClick={this.handleSubmit}>提交</div>
            </div>
        )
    }
}
const form={password:{
    fileName:'m',msg:''
},userName:{
        fileName:'username',msg:''
    }}

High=formProvider(form,High);

export default High;
